package com.example.localbites;

import com.example.constants.StringConstant;
import com.example.yelp.service.beans.YelpSearchResult;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class TabContent extends TabActivity {

	private StringConstant con = new StringConstant();
	private YelpSearchResult result;
	private String cusineType;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tab);
		
		Resources res = getResources();
		TabHost tabHost = getTabHost(); 
		
		result = (YelpSearchResult) getIntent().getSerializableExtra(con.SEARCH_RESULT);
		cusineType = getIntent().getStringExtra(con.CUSINE_TYPE);
		
		// Nearby tab
		Intent intentNearby = new Intent().setClass(this, RestaurantList.class);
		intentNearby.putExtra(con.SEARCH_RESULT, result);
		intentNearby.putExtra(con.CUSINE_TYPE, cusineType);
		TabSpec tabSpecNearby = tabHost
		  .newTabSpec("Nearby Restaurants")
		  .setIndicator("", res.getDrawable(R.drawable.icon_android_config))
		  .setContent(intentNearby);

		
		// Favorite tab
		Intent intentFavorite = new Intent().setClass(this, Favorite_list.class);
		TabSpec tabSpecFavorite = tabHost
		  .newTabSpec("Favorite List")
		  .setIndicator("", res.getDrawable(R.drawable.icon_apple_config))
		  .setContent(intentFavorite);
		
		// add all tabs 
		tabHost.addTab(tabSpecNearby);
		tabHost.addTab(tabSpecFavorite);
		
		//set nearby tab as default (zero based)
		tabHost.setCurrentTab(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tab, menu);
		return true;
	}

}
